﻿package {
	import idv.cjcat.pyronova.nodes.BlendBuffer;
	import idv.cjcat.pyronova.nodes.Blur;
	import idv.cjcat.pyronova.nodes.Circle;
	import idv.cjcat.pyronova.nodes.Group;
	import idv.cjcat.pyronova.nodes.Node;
	import idv.cjcat.pyronova.nodes.PushBuffer;
	import idv.cjcat.pyronova.utils.BlendMode;
	
	public class Main extends PyronovaExample {
		
		private var group:Group;
		
		public function Main():void {
			super("BlurryTrail", 0x101010);
		}
		
		override protected function buildPreprocessor():Node {
			//push new buffer
			return new PushBuffer();
		}
		
		override protected function buildRoot():Node {
			group = new Group(
				new Circle(50, 0, 15, 0xFF101080), 
				new Circle(-50, 0, 15, 0xFF101080)
			);
			group.position.set(160, 100);
			
			return group;
		}
		
		override protected function buildPostprocessor():Node {
			//fade & collapse
			return new Group(
				new BlendBuffer(BlendMode.ADD), 
				new Blur(2)
			);
		}
		
		override protected function mainLoop():void {
			group.rotation += 1;
		}
	}
}